#include<cstdio>//uncle-lu
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

struct node{
	int x,y,h,l;
};
node line[10010];
int n;

int main()
{
	int xx, yy;
	read(n);
	for(int i=1;i<=n;++i)
	{
		read(line[i].x);read(line[i].y);read(line[i].h);read(line[i].l);
	}
	read(xx);read(yy);
	for(int i=n;i>=1;--i)
	{
		if(line[i].x>xx)continue;
		if(line[i].y>yy)continue;
		if( line[i].x+line[i].h>=xx && line[i].y+line[i].l>=yy)
		{
			printf("%d",i);
			return 0;
		}
	}
	printf("-1");
	return 0;
}
